home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
lisp
/
elk-2_0.lha
/
elk-2.0
/
examples
/
scheme
/
perm
< prev
next >
Wrap
Text File
|
1992-08-05
|
399b
|
22 lines
;;; -*-Scheme-*-
(define (perm x)
(if (null? x)
(list x)
(let ((res '()))
(for-each
(lambda (e)
(set! res (append res (map (lambda (p) (cons e p))
(perm (del e x))))))
x) res)))
(define (del e l)
(let loop ((r l))
(if (pair? r)
(if (eq? e (car r))
(loop (cdr r))
(cons (car r) (loop (cdr r))))
'())))
(print (perm '(a b c d)))